package cn.jly.flink.sideoutput.impl;

import cn.jly.flink.sideoutput.MyRedisCommandContainer;
import lombok.extern.slf4j.Slf4j;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.Map;
import java.util.Set;

/**
 * @PackageName cn.jly.flink.sideoutput.impl
 * @ClassName RedisCommandContainerImpl
 * @Description
 * @Author 姬岚洋
 * @Date 2021/1/18 上午 9:22
 */
@Slf4j
public class MyRedisCommandContainerImpl implements MyRedisCommandContainer {

    private final JedisCluster jedisCluster;

    public MyRedisCommandContainerImpl(Set<HostAndPort> nodes) {
        this.jedisCluster = new JedisCluster(nodes);
    }

    @Override
    public Map<String, String> hgetAll(String key) {
        return jedisCluster.hgetAll(key);
    }

    @Override
    public void close() {
        if (jedisCluster != null) {
            jedisCluster.close();
        }
    }
}
